using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NTTHAO.Web.BL.Survey;
using System.Collections.Specialized;

public partial class admin_webparts_Plug_ins_Survey_SurveyDetail : System.Web.UI.UserControl
{
    public Survey _Survey = null;
    public DataTable _SurveyDetail = null;
    public NameValueCollection _SelectedCount = new NameValueCollection();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {
                Survey sur = new Survey(Int32.Parse(Request.QueryString["surveyid"]));
                if (sur.ID < 1)
                {
                    throw new Exception();
                }
                this._Survey = sur;

                SurveyDetail detail = new SurveyDetail();
                DataSet ds = detail.GetAllBySurveyID(_Survey.ID);

                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    this._SurveyDetail = ds.Tables[0];
                }

                SurveySelected selected = new SurveySelected();
                DataSet ds2 = selected.CountBySurvey(this._Survey.ID);

                if (ds2 != null)
                {
                    for (int i = 0; i < ds2.Tables[0].Rows.Count; i++)
                    {
                        DataRow rowi = ds2.Tables[0].Rows[i];
                        int detailID = (int)rowi["ID"];
                        int count = (int)rowi["SelectedCount"];

                        _SelectedCount.Add(detailID.ToString(), count.ToString());
                    }
                }
            }
            catch (Exception)
            {
                Response.Redirect("?type=" + Request.QueryString["type"] + "&name=" + Request.QueryString["name"], false);
            }
        }
    }
}
